package gui;

import java.awt.Color;
import java.awt.Component;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Insets;
import java.awt.RenderingHints;

import javax.swing.border.Border;

public class RoundedBorder implements Border {
    
    private int radius;
	private Color bgColor;
    
    public RoundedBorder(int radius, Color bgColor) {
        this.radius = radius;
        this.bgColor = bgColor;
    }

    public boolean isBorderOpaque() {
        return true;
    }

	public Insets getBorderInsets(Component c) {
		return new Insets(this.radius, this.radius, this.radius, this.radius);
	}
	public void paintBorder(Component c, Graphics g, int x, int y, int width,
			int height) {
		Graphics2D g2 = (Graphics2D)g;

		g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, // Anti-alias!
		        RenderingHints.VALUE_ANTIALIAS_ON);
		g2.setColor(bgColor);
		g2.fillRoundRect(x+3,y+3,width-6,height-6,radius,radius);
		g2.setColor(Color.BLACK);
		g2.drawRoundRect(x+3,y+3,width-6,height-6,radius,radius);
		
	}
}